<?php
/**
 * @投融类
 * 1、投融事件list
 * 2、投融事件详情
 * 3、投融机构list
 * 4、投融机构详情
 * @作者
 * 万全强（php）
 */

namespace app\controller;

use app\controller\HomeBase;
use think\facade\Db;

use app\model\InvestEventModel;
use app\model\InvestOrganModel;


class Invest extends HomeBase
{
	
	private $InvestEventModel;
	private $InvestOrganModel;
	public function __construct(){
		
		parent::__construct();
		$this->InvestEventModel=new InvestEventModel();
		$this->InvestOrganModel=new InvestOrganModel();
	}
	
	/**
	 * 投融事件列表
	 *
	 * @return void
	 */
	public function GetInvestEventList()
	{
		$where="  a.status=1  ";
		
		$field="a.id,a.event_name,a.turns,a.invest_time,a.invest_money_str,a.country_id,a.province_id,a.city_id,a.area_id";
		
		$condition=[];
		
		/***关键字*/
		$keywords=request()->param('keywords','','trim');
		if(!empty($keywords)){
			$condition['keywords']=$keywords;
		}
		/***行业*/
		$industry_id=request()->param('industry_id',0,'intval');
		if(!empty($industry_id)){
			$condition['industry_id']=$industry_id;
		}
		/***类型*/
		$type_id = request()->param('type_id', 0, 'intval');
		if (!empty($type_id)) {
			$condition['type_id']=$type_id;
		}
		/***云端产业链*/
		$chain_id=request()->param('chain_id',0,'intval');
		if(!empty($chain_id)){
			$condition['chain_id']=$chain_id;
		}
		/***地方产业链*/
		$yun_chain_id=request()->param('yun_chain_id',0,'intval');
		if(!empty($yun_chain_id)){
			$condition['yun_chain_id']=$yun_chain_id;
		}
		
		/***城市*/
		$city_id=request()->param('city_id',0,'intval');
		if(!empty($city_id)){
			$condition['city_id']=$city_id;
		}
		
		
		$listobj=$this->InvestEventModel->GetList($field,$condition);
		
		
		return json(['status'=>1,'msg'=>'获取成功','data'=>$listobj]);
	}
	/**
	 * 投融详情
	 *
	 * @return void
	 */
	public function GetInvestEventDetail()
	{
		$param=request()->param();
		$id=isset($param['id'])?intval($param['id']):0;
		$result=$this->InvestEventModel->detail($id);
		
		return json(['status'=>1,'msg'=>'获取成功','data'=>$result]);
		
	}
	/**
	 * 投融机构列表
	 *
	 * @return void
	 */
	public function GetInvestOrganList()
	{
		$where="  a.status=1  ";
		
		$field="a.id,a.organ_name,a.turns,a.invest_nums,a.country_id,a.province_id,a.city_id,a.area_id";
		
		$condition=[];
		
		/***关键字*/
		$keywords=request()->param('keywords','','trim');
		if(!empty($keywords)){
			$condition['keywords']=$keywords;
		}
		/***行业*/
		$industry_id=request()->param('industry_id',0,'intval');
		if(!empty($industry_id)){
			$condition['industry_id']=$industry_id;
		}
		/***类型*/
		$type_id = request()->param('type_id', 0, 'intval');
		if (!empty($type_id)) {
			$condition['type_id']=$type_id;
		}
		/***云端产业链*/
		$chain_id=request()->param('chain_id',0,'intval');
		if(!empty($chain_id)){
			$condition['chain_id']=$chain_id;
		}
		/***地方产业链*/
		$yun_chain_id=request()->param('yun_chain_id',0,'intval');
		if(!empty($yun_chain_id)){
			$condition['yun_chain_id']=$yun_chain_id;
		}
		
		/***城市*/
		$city_id=request()->param('city_id',0,'intval');
		if(!empty($city_id)){
			$condition['city_id']=$city_id;
		}
		
		
		$listobj=$this->InvestOrganModel->GetList($field,$condition);
		
		
		return json(['status'=>1,'msg'=>'获取成功','data'=>$listobj]);
	}
}
